package com.aifast.common.base;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;

import java.util.HashMap;

/**
 * 驼峰式结果集map封装工具类
 * @Author fujian
 * @since 2022/1/6 11:32
 */
public class Kv<K,V> extends HashMap<K,V> {

    private static final long serialVersionUID = 3429436500626953201L;

    @Override
    public V put(K key, V value) {
        key = underlineToCamelCase(Convert.toStr(key));
        return super.put(key, value);
    }

    private K underlineToCamelCase(String toStr) {
        return (K) StrUtil.toCamelCase(toStr);
    }

    public static Kv build(){return new Kv();}

    public Kv set(K key,V value){
        super.put(key,value);
        return this;
    }

}
